// @ts-nocheck
function setScssRules(_rules) {
  const keys = Object.keys(_rules)
  const rules = {}
  for (let i = 0; i < keys.length; ++i) {
    const key = keys[i]
    rules[`scss/${key}`] = _rules[key]
  }
  return rules
}

export default {
  extends: ['stylelint-config-standard', 'stylelint-config-recommended-vue'],
  overrides: [
    {
      files: ['**/*.scss'],
      customSyntax: 'postcss-scss',
    },
  ],
  plugins: ['stylelint-scss'],
  rules: {
    // https://stylelint.io/user-guide/rules/#invalid
    'block-no-empty': true,
    'comment-no-empty': true,
    'no-empty-source': true,

    'color-no-invalid-hex': true,
    'function-calc-no-unspaced-operator': true,
    'named-grid-areas-no-invalid': true,

    'declaration-block-no-duplicate-properties': true,
    'font-family-no-duplicate-names': true,

    'annotation-no-unknown': true,
    'at-rule-no-unknown': null,
    'property-no-unknown': [true, { ignoreProperties: ['composes'] }],
    'unit-no-unknown': true,
    'selector-pseudo-class-no-unknown': [true, { ignorePseudoClasses: ['deep', 'global'] }],
    'selector-pseudo-element-no-unknown': true,
    'no-unknown-animations': true,
    'function-no-unknown': [
      true,
      {
        ignoreFunctions: ['v-bind'],
      },
    ],

    'declaration-block-no-shorthand-property-overrides': true,
    'no-descending-specificity': true,
    'font-family-no-missing-generic-family-keyword': true,
    'property-no-vendor-prefix': [
      true,
      {
        ignoreProperties: ['mask-image'],
      },
    ],

    'at-rule-empty-line-before': [
      'always',
      {
        except: ['first-nested', 'blockless-after-same-name-blockless'],
        ignore: ['after-comment', 'inside-block'],
      },
    ],

    'selector-class-pattern': null,

    // https://github.com/stylelint-scss/stylelint-scss/blob/master/README.md
    ...setScssRules({
      'at-mixin-named-arguments': [
        'always',
        {
          ignore: ['single-argument'], // 忽略单参数情况
        },
      ],
      'at-mixin-argumentless-call-parentheses': 'always',
      'no-duplicate-dollar-variables': [
        true,
        { ignoreInside: ['at-rule', 'nested-at-rule'], ignoreInsideAtRules: ['if', 'mixin'] },
      ],
    }),
  },
}
